package io.gitee.tuo_tuo.jfinaldevassistance.interceptors;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.log.Log;
import io.gitee.tuo_tuo.jfinaldevassistance.common.Rst;

/**
 * 全局异常处理器
 * @author tuotuo
 *
 */
public class GlobalExceptionInterceptor implements Interceptor{
	
	private static final Log log = Log.getLog(GlobalExceptionInterceptor.class);
	
	@Override
	public void intercept(Invocation inv) {
		try{
			inv.invoke();
		}catch(Exception exception){
			log.equals(exception.getLocalizedMessage());
			exception.printStackTrace();
            inv.getController().renderJson(Rst.fail("系统异常 : " + exception.getMessage()));
		}
	}

}
